﻿using Twitter.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;

namespace Twitter.Drivers
{
    public class FavesPartDriver : ContentPartDriver<FavesPart>
    {
        protected override DriverResult Display(FavesPart part, string displayType, dynamic shapeHelper)
        {
            return ContentShape("Parts_Faves",
                                () => shapeHelper.Parts_Faves(Username: part.Username,
                                                                Width: part.Width,
                                                                Height: part.Height,
                                                                WidgetTitle: part.WidgetTitle,
                                                                Caption: part.Caption,
                                                                BackgroundShellColor: part.BackgroundShellColor,
                                                                ShellColor: part.ShellColor,
                                                                TweetsBackgroundColor: part.TweetsBackgroundColor,
                                                                TweetsColor: part.TweetsColor,
                                                                TweetsLinksColor: part.TweetsLinksColor,
                                                                NumberOfTweets: part.NumberOfTweets,
                                                                ScrollBar: part.ScrollBar,
                                                                Loop: part.Loop,
                                                                Live: part.Live,
                                                                HashTags: part.HashTags,
                                                                Timestamp: part.Timestamp,
                                                                Avatars: part.Avatars,
                                                                Behavior: part.Behavior,
                                                                Interval: part.Interval));
        }

        //GET
        protected override DriverResult Editor(FavesPart part, dynamic shapeHelper)
        {
            return ContentShape("Parts_Faves_Edit",
                                () => shapeHelper.EditorTemplate(TemplateName: "Parts/Twitter/Faves", Model: part));
        }

        //POST
        protected override DriverResult Editor(FavesPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            updater.TryUpdateModel(part, Prefix, null, null);
            return Editor(part, shapeHelper);
        }
    }
}